function logout(){
	$.ajax({
		type: "get",
		url: "../loginController/logoutUser",
		dataType: 'json',
		contentType:"application/json;charset=UTF-8",
		success: function(data, textStatus) {
		if (data.success) window.location.href="../login/index.html";
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
		alert("Error:"+textStatus);
		alert(errorThrown.toString());
		}
		});
}

function cookieShopLogout(){
	$.ajax({
		type: "get",
		url: "../../loginController/logoutUser",
		dataType: 'json',
		contentType:"application/json;charset=UTF-8",
		success: function(data, textStatus) {
		  if (data.success) window.location.href="../../custpages/index.html";
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
		alert("Error:"+textStatus);
		alert(errorThrown.toString());
		}
		});
}

function cookieShopFrontLogout(){
	$.ajax({
		type: "get",
		url: "../loginController/logoutUser",
		dataType: 'json',
		contentType:"application/json;charset=UTF-8",
		success: function(data, textStatus) {
		  if (data.success) window.location.href="../custpages/index.html";
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
		alert("Error:"+textStatus);
		alert(errorThrown.toString());
		}
		});
}

function checkAdminAccess(){
	$.ajax({
		type: "get",
		url: "../../loginController/canAdminAccess",
		dataType: 'json',
		success: function(data, textStatus) {
			if (!(data.success && data.canAccess == true)){
				window.location.href="../../custpages/index.html"
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function isAdmin(){
  var isAdmin = false;
	$.ajax({
		type: "get",
		url: "../../loginController/canAdminAccess",
		dataType: 'json',
		async: false,
		success: function(data, textStatus) {
			if (data.success && data.canAccess == true){
			   isAdmin = true;
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
	return isAdmin;
}

function isLogin(){
  var isLogin = false;
	$.ajax({
		type: "get",
		url: "../../loginController/isLogin",
		dataType: 'json',
		async: false,
		success: function(data, textStatus) {
			if (data.success && data.isLogin == true){
			   isLogin = true;
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
	return isLogin;
}
